home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_43696.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  25 lines

  1. -- card: 43696 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. CONSTRUCTORS & DESTRUCTORS
  11.  
  12. As demonstrated above, it is customary to provide an init() method for initializing TC objects immediately after allocation.  (C++ provides a feature to automate initialization, which is not available in TC.)  The init() method may itself perform additional allocation as dictated by the programmer.
  13.  
  14. It is also customary to send a destroy() message to the object immediately before deallocating the object.  The destroy() method should deallocate any space allocated by the init() method.  (Again, C++ provides for "destructors" which are automatically called when the object is deallocated.)
  15.  
  16. The space pointed to by an object pointer is deallocated in TC using the delete() function, while C++ provides the 'delete' operator for this purpose.  It simply deallocates the object pointed to by its argument.
  17.  
  18.     jack->destroy();       /* C++ provides automated "destructors" */
  19.     delete(jack);             /* in C++ parentheses are not needed */
  20.  
  21.  
  22.  
  23. -- part contents for background part 7
  24. ----- text -----
  25. 119